package com.examples.painting;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;

public class ResizingRedrawing {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
	    Display display = Display.getDefault();
	    final Color white = display.getSystemColor(SWT.COLOR_WHITE);
	    final Color gray = display.getSystemColor(SWT.COLOR_GRAY);
	    
	    int style = SWT.SHELL_TRIM | SWT.NO_REDRAW_RESIZE;
	    final Shell shell = new Shell(display, style);
	    
	    shell.setBackground(gray);
	    shell.setSize(200, 200);
	    shell.open();
	    shell.addListener(SWT.Paint, new Listener() {
	        public void handleEvent(Event event) {
	            GC gc = event.gc;
	            gc.setBackground(white);
	            gc.fillRectangle(shell.getClientArea());
	        }
	    });
	    shell.setSize(250, 250);
	    while (!shell.isDisposed()) {
	        if (!display.readAndDispatch()) display.sleep();
		}
	}
}